<?php

class PageController extends HomeController
{
    public function actionView($id)
    {
        $page = Page::model()->findByPk($id);
        if($page){
            $this->render('page/view',array('model'=>$page));
        }
        else{
            $error = Yii::app()->errorHandler->error;
            $this->render('error', $error);
        }
    }

    /**
     * This is the action to handle external exceptions.
     */
    public function actionError()
    {
        if ($error = Yii::app()->errorHandler->error) {
            if (Yii::app()->request->isAjaxRequest)
                echo $error['message'];
            else
                $this->render('error', $error);
        }
    }

}